package com.zjitc.dao;

import com.alibaba.druid.pool.DruidDataSource;
import org.springframework.jdbc.core.JdbcTemplate;

public class SingletonTemplate {
    private static JdbcTemplate jdbcTemplate=null;
    public static JdbcTemplate getJdbcTemplate(){
        if (jdbcTemplate==null){
            jdbcTemplate=new JdbcTemplate();

            //初始化
            DruidDataSource druidDataSource=new DruidDataSource();
            druidDataSource.setDriverClassName("com.mysql.jdbc.Driver");
            druidDataSource.setUrl("jdbc:mysql://127.0.0.1:3306/user_management");
            druidDataSource.setUsername("root");
            druidDataSource.setPassword("root");

            jdbcTemplate.setDataSource(druidDataSource);

        }
        return jdbcTemplate;

    }
}
